package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.NianSheng;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
 *  @author 雨安
 *  类名： NianShengMapper
 *  创建时间：2024/4/13
 */
@Repository
public interface NianShengMapper extends BaseMapper<NianSheng> {
    @Select("SELECT t1.*\n" +
            "FROM nianshen t1\n" +
            "JOIN (\n" +
            "    SELECT carno, MAX(nextcheckdate) AS max_nextcheckdate\n" +
            "    FROM nianshen\n" +
            "    GROUP BY carno\n" +
            ") t2\n" +
            "ON t1.carno = t2.carno AND t1.nextcheckdate = t2.max_nextcheckdate")
    List<NianSheng> selectAllCar();

}
